﻿using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Mbl.ParameterizedTest.AcceptanceTests.CalculatorTests
{
    [TestClass]
    public class AdditionTests
    {        
        [TestMethod]
        public void Adding_two_numbers_gives_the_sum()
        {            
            ParameterizedTest
                .Setup(() => new Calculator())
                .For<int, int, int>(c => c.Add)
                .Given(2, 2).Expect(4).Because("It's the sum")
                .Given(0, 0).Expect(0).Because("Zero is the additive identity.")
                .Evaluate();
        }

        [TestMethod]   
        [ExpectedException(typeof(AssertFailedException))]
        public void Wrong_result_fails_test()
        {            
            ParameterizedTest
                .Setup(() => new Calculator())
                .For<int, int, int>(calculator => calculator.Add)
                .Given(2, 2).Expect(5).Because("It's the sum")                
                .Evaluate();
        }

        [TestMethod]
        [ExpectedFailedTestCases(2)]
        public void Tests_can_be_created_withput_setup()
        {
            var calculator = new Calculator();
            
            ParameterizedTest                
                .For((int a, int b) => calculator.Add(a, b))
                .Given(2, 2).Expect(4).Because("It's right")                
                .Given(2, 2).Expect(5).Because("It's wrong.")
                .Evaluate();
        }        
    }
}
